let request = require("request");
let fs = require("fs");
let url = 'https://interface.sina.cn/news/wap/fymap2020_data.d.json';

request.get(url, {}, function (err, result, body) {
    if (err) {
        console.log(err);
    } else {
        let obj = JSON.parse(body);
        let list = obj.data.list;
        console.log('国内地区：：：：：：：');
        list.forEach(ele => {
           console.log(ele.name+ele.ename);  //地区中文名
        //    console.log(ele.ename); //地区英文名
           console.log('感染人数:'+ele.value);
        })

        // let str = JSON.parse(body);
        let data = obj.data;
        let keys = [];
        for (let key in data) {
            // console.log(key);   //打印出data下times，mtime，cachetime....
            keys.push(key);
        }
        // console.log(keys);
        console.log(data[Object.keys(data)[0]]);


        console.log("历史确诊记录：：：：：：：");
        let history = obj.data.otherhistorylist;
        history.forEach(ele => {
            console.log("确诊人数："+ele.certain +"人");  //地区中文名
         //    console.log(ele.ename); //地区英文名
            console.log('时间：'+ele.date);
         })

    }
    // fs.writeFileSync('./yiqingData.html',body);
})